package be.vdab.dao;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;


import be.vdab.entities.Saus;

public class SausenDAO {

	static private Map<Long,Saus> sausen = new ConcurrentHashMap<Long, Saus>();
	
	static{
		sausen.put(1L, new Saus(1L, "cocktail",
				new String[] { "mayonaise", "room", "gember", "tomatenketchup",
				"cognac", "sherry", "peper", "zout" }));
		sausen.put(2L, new Saus(2L, "mayonaise", new String[] { "eidooier", "olie",
				"azijn", "mosterd", "kruiden", "peper", "zout" }));
		sausen.put(3L, new Saus(3L, "mosterd", new String[] { "mosterdzaden",
				"azijn", "water", "suiker", "zout", "peper", "mierikswortel" }));
		sausen.put(4L, new Saus(4L, "tartare", new String[] { "mayonaise", "ei",
				"peterselie", "sjalotjes", "augurk", "kappertjes", "bieslook" }));
		sausen.put(5L, new Saus(5L, "vinaigrette", new String[] { "olijfolie",
				"wijnazijn", "zout", "peper", "tuinkruiden", "mosterd",
				"knoflook" }));		
	}
	
	public List<Saus> findAll(){
		return new ArrayList<Saus>(sausen.values());
	}
	
	public List<Saus> findByIngredient(String ingredient){
		List <Saus> resultaat = new ArrayList<Saus>();
		for (Saus saus : sausen.values()){
			if (Arrays.asList(saus.getIngredienten()).contains(ingredient)){
				resultaat.add(saus);
			}			
		}
		return resultaat;
	}
	
	public void delete (long nummer){
		sausen.remove(nummer);
	}
	
}
